﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using JM.JCY.BusinessEntity;
using JM.JCY.Proxy;
using NCS.IConnect.ApplicationContexts;
using JM.JCY.Common;
using JM.JCY.Common.Utilities;
using Microsoft.SharePoint;

namespace JM.JCY.SharePointComponent.IncorruptArchives.CreatePersonImportantReport
{
    public partial class CreatePersonImportantReportUserControl : UserControl
    {
        public string _userName
        {
            set { ViewState["_userName"] = value; }
            get { return (string)ViewState["_userName"]; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (ApplicationContext.Current.UserName != null)
            {
                _userName = ApplicationContext.Current.UserName;
            }

            if (!IsPostBack)
            {

            }
        }

        protected void imgSubmit_Click(object sender, ImageClickEventArgs e)
        {
            using (IncorruptProxy proxy = new IncorruptProxy())
            {
                var newDT = new IncorruptDataSet.T_PersonImportantReportDataTable();
                var newRow = newDT.NewT_PersonImportantReportRow();

                newRow.Reporter = this.txtReporter.Text;
                newRow.PoliticSituation = this.txtPoliticSituation.Text;
                newRow.ReportDate = this.dtReportDate.SelectedDate;

                newRow.Dept_Position = this.txtDept_Position.Text;
                newRow.Content_Reason = this.txtContent_Reason.Text;
                newRow.Approval = this.txtApproval.Text;

                JCYUtility.UpdateCommonFields(newRow, "Iori");

                newDT.AddT_PersonImportantReportRow(newRow);
                proxy.UpdatePersonImportantReport(newDT);
                Response.Redirect("PersonImportantReport.aspx");
            }
        }

        protected void imgCancel_Click(object sender, ImageClickEventArgs e)
        {
            Response.Redirect("PersonImportantReport.aspx");
        }
    }
}
